package com.xzzz.irda.guardcat.core.metric.gc;


import com.xzzz.irda.guardcat.core.metric.memory.BaseMemoryUsageInfo;

import java.io.Serializable;

/**
 * GC 时【前后】的虚拟机的内存使用信息
 *
 * @author xzzz
 * @since 1.0.0
 */
public class GcMemoryUsageInfo implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * JIT 代码缓存区内存使用信息
     */
    private final BaseMemoryUsageInfo codeCacheUsage;

    /**
     * 元空间内存使用信息
     */
    private final BaseMemoryUsageInfo metaspaceUsage;

    /**
     * 类指针压缩空间内存使用信息
     */
    private final BaseMemoryUsageInfo compressedClassSpaceUsage;

    /**
     * 新生代内存使用信息
     */
    private final BaseMemoryUsageInfo edenSpaceUsage;

    /**
     * 幸存代内存使用信息
     */
    private final BaseMemoryUsageInfo survivorSpaceUsage;

    /**
     * 老年代内存使用信息
     */
    private final BaseMemoryUsageInfo oldGenUsage;

    public GcMemoryUsageInfo(BaseMemoryUsageInfo codeCacheUsage, BaseMemoryUsageInfo metaspaceUsage, BaseMemoryUsageInfo compressedClassSpaceUsage, BaseMemoryUsageInfo edenSpaceUsage, BaseMemoryUsageInfo survivorSpaceUsage, BaseMemoryUsageInfo oldGenUsage) {
        this.codeCacheUsage = codeCacheUsage;
        this.metaspaceUsage = metaspaceUsage;
        this.compressedClassSpaceUsage = compressedClassSpaceUsage;
        this.edenSpaceUsage = edenSpaceUsage;
        this.survivorSpaceUsage = survivorSpaceUsage;
        this.oldGenUsage = oldGenUsage;
    }

    public BaseMemoryUsageInfo getCodeCacheUsage() {
        return codeCacheUsage;
    }

    public BaseMemoryUsageInfo getMetaspaceUsage() {
        return metaspaceUsage;
    }

    public BaseMemoryUsageInfo getCompressedClassSpaceUsage() {
        return compressedClassSpaceUsage;
    }

    public BaseMemoryUsageInfo getEdenSpaceUsage() {
        return edenSpaceUsage;
    }

    public BaseMemoryUsageInfo getSurvivorSpaceUsage() {
        return survivorSpaceUsage;
    }

    public BaseMemoryUsageInfo getOldGenUsage() {
        return oldGenUsage;
    }

    @Override
    public String toString() {
        return "GcMemoryUsageInfo{" +
                "JIT代码缓存区内存信息=" + codeCacheUsage +
                ", 元空间内存信息=" + metaspaceUsage +
                ", 类压缩数据区内存信息=" + compressedClassSpaceUsage +
                ", 新生代=" + edenSpaceUsage +
                ", 幸存代=" + survivorSpaceUsage +
                ", 老年代=" + oldGenUsage +
                '}';
    }
}
